const webpack = require('webpack')
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')

module.exports = {
    context: path.resolve(__dirname, '../'),
    entry: {
        // 登录
        login: './src/login.js',
        // 注册
        signup: './src/signup.js',
        // 代理商主页
        agent: './src/agent.js',
        // 下单
        order: './src/order.js',
        // 查询订单列表
        search: './src/search.js',
        // 收益明细
        profit: './src/profit.js'
    },
    output: {
        filename: 'js/[name].js',
        path: path.resolve(__dirname, '../dist'),
        publicPath: '/dist/'
    },
    module: {
        rules: [
            {
                test: /\.css$/,
                use: ['style-loader', 'css-loader']
            },
            {
                test: /\.js$/,
                use: 'babel-loader',
                exclude: /node_modules/
            },
            {
                test: /\.tag$/,
                exclude: /node_modules/,
                use: [{
                    loader: 'riot-tag-loader',
                    options: {hot: false}
                }]
            }
        ]
    },
    plugins: [
        new HtmlWebpackPlugin({
            filename: 'pages/login.html',
            title: '登录',
            chunks: ['login'],
            template: './html/login.html',
            publicPath: '/dist/'
        }),
        new HtmlWebpackPlugin({
            filename: 'pages/signup.html',
            title: '注册',
            chunks: ['signup'],
            template: './html/signup.html',
            publicPath: '/dist/'
        }),
        new HtmlWebpackPlugin({
            filename: 'pages/agent.html',
            title: '代理商',
            chunks: ['agent'],
            template: './html/agent.html',
            publicPath: '/dist/'
        }),
        new HtmlWebpackPlugin({
            filename: 'pages/order.html',
            title: '客户扫码下单',
            chunks: ['order'],
            template: './html/order.html',
            publicPath: '/dist/'
        }),
        new HtmlWebpackPlugin({
            filename: 'pages/search.html',
            title: '订单查询',
            chunks: ['search'],
            template: './html/search.html',
            publicPath: '/dist/'
        }),
        new HtmlWebpackPlugin({
            filename: 'pages/profit.html',
            title: '收益记录',
            chunks: ['profit'],
            template: './html/profit.html',
            publicPath: '/dist/'
        })
    ]
}